package com.roy;

import org.zywx.wbpalmstar.engine.universalex.EUExCallback;

import android.content.Context;
import android.util.Log;

import com.tencent.android.tpush.XGPushBaseReceiver;
import com.tencent.android.tpush.XGPushClickedResult;
import com.tencent.android.tpush.XGPushConfig;
import com.tencent.android.tpush.XGPushRegisterResult;
import com.tencent.android.tpush.XGPushShowedResult;
import com.tencent.android.tpush.XGPushTextMessage;

public class CustomPushReceiver extends XGPushBaseReceiver {

	@Override
	public void onDeleteTagResult(Context arg0, int arg1, String arg2) {
		// TODO Auto-generated method stub
		Log.i("PushRec", "删除标签结果：onDeleteTagResult " + arg2);

	}

	@Override
	public void onNotifactionClickedResult(Context arg0, XGPushClickedResult arg1) {
		// TODO Auto-generated method stub
		Log.i("PushRec", "获取的消息内容：onNotifactionClickedResult " + arg1.getContent() + " title" + arg1.getTitle());
		//UexXG.that.jsCallback("uexXG.cbXgPush", 1, EUExCallback.F_C_TEXT,"获取被点击的通知：onNotifactionClickedResult" + arg1.getContent() + " title" + arg1.getTitle()+" JSON:" + arg1.getCustomContent());

		if(!arg1.getCustomContent().isEmpty()){
			UexXG.that.jsCallback("uexXG.cbXgPush", 1, EUExCallback.F_C_JSON, "{\"cmd\":\""+arg1.getContent()+"\",json:" + arg1.getCustomContent()+"}");
		}else
		{
			UexXG.that.jsCallback("uexXG.cbXgPush", 1, EUExCallback.F_C_JSON, "{\"cmd\":\""+arg1.getContent()+"\",}");
		}
		
	}

	@Override
	public void onNotifactionShowedResult(Context arg0, XGPushShowedResult arg1) {
		// TODO Auto-generated method stub
		//Log.i("PushRec", "获取被展示的通知：onNotifactionShowedResult " + arg1.getContent() + " title" + arg1.getTitle());
		//UexXG.that.jsCallback("uexXG.cbXgPush", 1, EUExCallback.F_C_TEXT,"获取被展示的通知：onNotifactionShowedResult " + arg1.getContent() + " title" + arg1.getTitle()+" JSON:" + arg1.getCustomContent());
	}

	@Override
	public void onRegisterResult(Context arg0, int arg1, XGPushRegisterResult arg2) {
		// TODO Auto-generated method stub
		Log.i("PushRec", "注册成功：onRegisterResult " + arg2.getDeviceId());
	}

	@Override
	public void onSetTagResult(Context arg0, int arg1, String arg2) {
		// TODO Auto-generated method stub
		Log.i("PushRec", "设置标签结果：onSetTagResult " + arg2);

	}

	@Override
	public void onTextMessage(Context context, XGPushTextMessage message) {
		String cmd = message.getContent();
		Log.i("PushRec", "获取的消息内容：" + cmd);
		if (cmd != null) {
//			UexXG.that.jsCallback("uexXG.cbXgPush", 1, EUExCallback.F_C_JSON, "{\"cmd\":\""+cmd+"\",json:" + message.getCustomContent()+"}");
			Log.i("PushRec", "收到消息：：" + cmd +" JSON:" + message.getCustomContent());
			if(!message.getCustomContent().isEmpty()){
				UexXG.that.jsCallback("uexXG.cbXgPush", 1, EUExCallback.F_C_JSON, "{\"cmd\":\""+message.getContent()+"\",json:" + message.getCustomContent()+"}");
			}else
			{
				UexXG.that.jsCallback("uexXG.cbXgPush", 1, EUExCallback.F_C_JSON, "{\"cmd\":\""+message.getContent()+"\",}");
			}
		}
		

		//uexXG.;
		
	}

	@Override
	public void onUnregisterResult(Context arg0, int arg1) {
		Log.i("PushRec", "反注册结果：onUnregisterResult" + arg1);

	}

}
